import sys
from datetime import datetime

def modify_num(num):
    num = 4
    print("num ref:{}".format(sys.getrefcount(num)))
    print("modify_num:{}".format(num))

def test_numbers():
    num = 3
    modify_num(num)
    print("num:{}".format(num))

####################

def modify_str(val):
    val = "test2"
    print("modify_str:{}".format(val))
    
def test_str():
    val = "test1"
    modify_str(val)
    print("str:{}".format(val))

####################

def modify_list(ls):
    ls[0] = 9
    print("modify_list:{}".format(ls))

def test_list():
    ls = [1,2,3]
    modify_list(ls)
    print("ls:{}".format(ls))

####################

def modify_set(st):
    st.remove(1)
    print("modify_set:{}".format(st))

def test_set():
    st = set([1,2,3])
    modify_set(st)
    print("st:{}".format(st))

####################

def modify_tuple(tp):
    refcount = sys.getrefcount(tp)
    print("modify_tuple not allowd, refcount:{}".format(refcount))


def test_tuple():
    tp = (1,2,3)
    modify_tuple(tp)
    print("tp:{}".format(tp))

####################

def modify_dict(dt):
    dt["name"] = "item2"
    print("modify_dict:{}".format(dt))

def test_dict():
    dt = { "name": "item1"}
    modify_dict(dt)
    print("dt:{}".format(dt))

####################

def modify_bool(bl):
    bl = False
    print("modify_bool:{}".format(bl))

def test_bool():
    bl = True
    modify_bool(bl)
    print("bl:{}".format(bl))

####################

def modify_none(ne):
    ne = 1
    print("modify_none:{}".format(ne))

def test_none():
    ne = None
    modify_none(ne)
    print("ne:{}".format(ne))

####################

def modify_custom(custom):
    custom.data = "data2"
    print("modify_custom, custom.data:{}".format(custom.data))

def test_custom():
    class MyStruct: 
        def __init__(self, val):
            self.data = val

    custom = MyStruct("data1")
    modify_custom(custom)
    print("custom.data:{}".format(custom.data))

####################

def modify_datetime(dt):
    print("modify_datetime not allowd. refcount")

def test_datetime():
    dt = datetime(2023,11,19)
    modify_datetime(dt)
    print("datetime:{}".format(dt))

def main():
    test_numbers()
    print("#################")
    test_str()
    print("#################")
    test_list()
    print("#################")
    test_set()
    print("#################")
    test_tuple()
    print("#################")
    test_dict()
    print("#################")
    test_bool()
    print("#################")
    test_none()
    print("#################")
    test_custom()
    print("#################")
    test_datetime()


if __name__ == "__main__":
    main()
